84C - Biathlon - CodeForces Solution


binary search implementation *1700

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>

using namespace std;

const int N = 10010, D = 20000;
int n, m, x, y, z, c[N], r[N], s[N];

vector<int> v[N<<2+1];

int main(){
    cin>>n;
    for (int i=1;i<=n; i++)
    {
        cin>>c[i]>>r[i];
        c[i]+=D;
        for(int j=c[i]-r[i];j<=c[i]+r[i];j++) v[j].push_back(i);
    }
    
    fill(s+1,s+n+1,-1);
    
    cin >> m;
    for (int i=1;i<=m;i++){
        cin >> x >> y;
        x+=D;
        for (auto j:v[x]) 
        if(s[j]==-1)
        if (y*y+(x-c[j])*(x-c[j])<=r[j]*r[j]) s[j] = i,z++;
    }
    cout << z << endl;
    
    for (int i=1;i<=n;i++) cout<<s[i]<<" ";
}


Comments

Submit
0 Comments
More Questions

1722F - L-shapes
1196B - Odd Sum Segments
1325D - Ehab the Xorcist
552B - Vanya and Books
1722E - Counting Rectangles
168A - Wizards and Demonstration
168B - Wizards and Minimal Spell
7A - Kalevitch and Chess
912B - New Year's Eve
1537C - Challenging Cliffs
879B - Table Tennis
1674E - Breaking the Wall
1282A - Temporarily unavailable
1366C - Palindromic Paths
336A - Vasily the Bear and Triangle
926A - 2-3-numbers
276D - Little Girl and Maximum XOR
1253C - Sweets Eating
1047A - Little C Loves 3 I
758D - Ability To Convert
733A - Grasshopper And the String
216A - Tiling with Hexagons
1351B - Square
1225A - Forgetting Things
1717A - Madoka and Strange Thoughts
1717B - Madoka and Underground Competitions
61B - Hard Work
959B - Mahmoud and Ehab and the message
802G - Fake News (easy)
1717C - Madoka and Formal Statement